void main() {
  // dynamic 动态类型 什么类型都可以 就是any
  List goodsList = [
    {"id": 1, "price": 22.68, "count": 3, "goods_name": "西瓜", "selectd": true},
    {"id": 2, "price": 11.99, "count": 3, "goods_name": "草莓", "selectd": true},
    {
      "id": 3,
      "price": 60.99,
      "count": 1,
      "goods_name": "车厘子",
      "selectd": false
    },
    {
      "id": 4,
      "price": 11.68,
      "count": 3,
      "goods_name": "平谷大桃",
      "selectd": false
    }
  ];

// fold相对于前端鸿蒙的reduce方法
// List中fold 和reduce 方法 都是累加计算 但是fold有初始值
  // 筛选所有的选中的商品
  double allValue = goodsList.where((item) => item["selectd"]).fold(
      0.0, (value, element) => value + element["count"] * element["price"]);
  print(allValue);
}
